//
//  HXbluetoothLinkStyleCell.h
//  HongxuanBluetooth
//
//  Created by 广州弘轩科技发展有限公司 on 2023/8/2.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
NS_ASSUME_NONNULL_BEGIN

@interface BlueToothManager : NSObject
@property (strong, nonatomic) CBCentralManager *centralManager;

+ (instancetype)shareInstance;

@property (copy, nonatomic) void (^_Nullable refershDeviceList)(NSMutableArray *list);
@property (copy, nonatomic) void (^_Nullable successfulConnectionBlock)(NSMutableArray *list);
@property (copy, nonatomic) void (^_Nullable ConnectionFailureBlock)(NSString *uuid);
@property (copy, nonatomic) void (^_Nullable dataBlock)(NSData *data);
@property (copy, nonatomic) void (^_Nullable datastrBlock)(NSString *datastr);
@property (copy, nonatomic) void (^_Nullable datalasttimeBlock)(NSString *lasttime);
@property (copy, nonatomic) void (^_Nullable RSSIBlock)(NSInteger rsii);
@property (copy, nonatomic) void (^_Nullable requestTimeoutBlock)(NSMutableArray *list);//设备请求超时返回
@property (copy, nonatomic) void (^_Nullable bluetoothConnectionReturnBlock)(void);//蓝牙连接返回
@property (copy, nonatomic) void (^_Nullable automaticLinkBlock)(void);//蓝牙自动连接
@property (copy, nonatomic) void (^_Nullable unitExceptionBlock)(void);//蓝牙设备异常

@property (copy, nonatomic) void (^_Nullable characteristicBlock)(CBCharacteristic *characteristic);//蓝牙characteristi

@property (strong, nonatomic) NSMutableArray *myDevices;//历史连接的设备
@property (assign, nonatomic) BOOL autoConnect;//是否自动连接历史连接的设备 YES连接  NO不连接
//@property (copy, nonatomic) NSString *oldUUID;//上一次连接的uuid 用来重连
-(void)StartScan;//开始扫描
-(void)stopScan;//停止扫描

-(void)popupstop;//停止弹窗

@property (strong, nonatomic) CBPeripheral *_Nullable connectPeripheral;
@property (strong, nonatomic) CBPeripheral *_Nullable towPeripheral;
@property (strong, nonatomic) NSDictionary *_Nullable adData;
@property (strong, nonatomic) CBCharacteristic *writeCharcteristic;
@property (strong, nonatomic) CBCharacteristic *towCharcteristic;
@property (strong, nonatomic) CBCharacteristic *charcteristic;
@property (copy, nonatomic) NSString *theMac;
@property (copy, nonatomic) NSString *uuid;
@property (assign, nonatomic) BOOL connectionState;//连接状态  yes已连接 NO 未连接
@property (assign, nonatomic) BOOL bluetoothDiscoverable;//是否打开了蓝牙

- (void)connectWithPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData macString:(NSString *)macString;//连接设备
-(void)reconnection:(NSString *)UUID;//通过uuid 连接
- (void)writeData:(NSData *)data;//发生数据
- (void)writeDatatow:(NSData *)data uuid:(NSString *)uuid;//发生数据2
-(void)disconnect;//断开链接
@property (strong,nonatomic) HXBluetoothConnectionDataModel *model;
@property (assign, nonatomic) BOOL isPopupStop;//停止弹窗
@end

NS_ASSUME_NONNULL_END
